package com.braveman.im.ui.adapter;


import android.text.TextUtils;
import android.widget.CompoundButton;

import com.braveman.im.R;
import com.braveman.im.bean.FriendshipListBean;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.qmuiteam.qmui.widget.QMUIRadiusImageView;

import java.util.ArrayList;
import java.util.List;

public class SelectFriendsAdapter extends BaseSectionQuickAdapter<FriendshipListBean, BaseViewHolder> {
    private QMUIRadiusImageView avater;
    private List<FriendshipListBean> list = new ArrayList<>();

    public SelectFriendsAdapter(int layoutResId, int sectionHeadResId, List data) {
        super(layoutResId, sectionHeadResId, data);
        list.addAll(data);
    }

    @Override
    protected void convertHead(BaseViewHolder helper, final FriendshipListBean item) {
        helper.setText(R.id.tv_item_home_head, item.header);
    }


    @Override
    protected void convert(BaseViewHolder helper, final FriendshipListBean item) {
        helper.setText(R.id.name, !TextUtils.isEmpty(item.friendRemark) ? item.friendRemark : item.friendName)
                .addOnClickListener(R.id.cb_activity_select_friend)
                .setOnCheckedChangeListener(R.id.cb_activity_select_friend, new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        item.isCheck = isChecked;
                    }
                }).setChecked(R.id.cb_activity_select_friend, item.isCheck);
        avater = helper.getView(R.id.avatar);
        avater.setCircle(false);
        Glide.with(mContext).load(item.friendAvatar).into(avater);

    }


}
